<template>
  <!-- 文件上传-->
  <el-dialog
    title="文件上传"
    :visible.sync="dialogFileVisible"
    @close="close"
    width="30%" class="dialog-style">
    <el-upload
      class="upload-demo"
      center
      drag
      :on-success="success"
      :data="formData"
      :headers="headers"
      :action="action"
      multiple>
      <i class="el-icon-upload"></i>
      <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
    </el-upload>
    </el-dialog>
</template>

<script>
import {baseUrl} from "@/apis/requests/requests";

export default {
  name: "UploadFile",
  props:['dialogVisible'],
  data() {
    return {
      action: `${baseUrl}/file/uploadFile`,
      headers: {
        'token': this.$store.state.token
      }
    }
  },
  computed:{
    formData(){
      let that = this;
      return {
        folderId : that.$store.state.folder.folderId
      }
    },
    // 使用计算属性修改组件状态，直接使用props修改会报warn
    dialogFileVisible:{
      get:function(){
        return this.dialogVisible
      },
      set:function(){}
    }
  },
  methods:{
    success(){
      this.$router.go(0)
    },
    close(){
      this.$emit('close')
    }
  }
}
</script>

